<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登陆页面</title>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="/css/login.css">
</head>
<body>
    <div class="login-container">
        <h2>用户登录</h2>
        <div class="input-group">
            <label>用户名：</label>
            <input type="text" id="username" placeholder="请输入用户名">
        </div>
        <div class="input-group">
            <label>密码：</label>
            <input type="password" id="password" placeholder="请输入密码">
        </div>
        <button id="login">登录</button>
    </div>
    <script>
        $('#login').click(function () {
            const data = {
                username: $('#username').val(),
                password: $('#password').val()
            };
            console.log(data)
            $.ajax({
                url: 'http://127.0.0.1:5000/login',
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(data),
                success: function (res) {
                    console.log(res)
                    alert(res.msg)
                     window.location.href = './keshihua.html';
                },
                error: function () {
                    console.log(res)
                    alert(res.msg)
            }
            })
        })
    </script>

</html>

